home *** CD-ROM | disk | FTP | other *** search
- Path: cs.tu-berlin.de!news
- From: Roman Lechtchinsky <wolfro@cs.tu-berlin.de>
- Newsgroups: comp.lang.c++
- Subject: Re: Forced override?
- Date: Tue, 05 Mar 1996 10:49:19 +0100
- Organization: Technical University of Berlin
- Message-ID: <313C0E1F.1FDE@cs.tu-berlin.de>
- References: <m1ybpgkvpa.fsf@zoger.ipost.com>
- NNTP-Posting-Host: 130.149.17.230
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0 (Win95; I)
-
- Bob Glickstein wrote:
- >
- > Quick question: is it possible to declare a virtual member function in
- > such a way that derived classes are *required* to override it? This
- > would have to work for classes both directly and indirectly derived.
- >
- > Thanks in advance.
-
- You have to declare a pure virtual function, e. g.:
-
- class A
- {
- virtual void foo() = 0;
- };
-
- Derived classes can only be instantiated if the foo is overridden.
-
- Bye
-
- Roman
-